home *** CD-ROM | disk | FTP | other *** search
/ BBS Toolkit / BBS Toolkit.iso / qbbs / msgsaver.zip / MSGSAVER.C next >
Text File  |  1989-04-05  |  1KB  |  53 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4. #include "qbbsstru.h"
  5.  
  6. #define MAXMSG 32767
  7.  
  8. FILE    *InfoFile;
  9.  
  10. info_record InfoBuff;
  11.  
  12. char    InfoName[] = "MSGINFO.BBS",
  13.     Error1[]   = "MSGINFO.BBS not found\n\n",
  14.         Error2[]   = "Invalid parameter\n",
  15.     StartMsg[] = "MSGSAVER - PD Software by Mark Murphy\n",
  16.     Syntax[]   = "\nSyntax:\n"
  17.              "    MSGSAVER [maxmsg]\n"
  18.              "\nWhere:\n"
  19.              "    maxmsg is an integer <= 32767.  Default\n"
  20.              "           value for maxmsg is 32000\n";
  21.  
  22. char    Param[6] = "";
  23. int    i, MaxMsg = 32000;
  24.  
  25.  
  26. main (int argc, char *argv[])
  27.  
  28. {
  29.   printf (StartMsg);
  30.   InfoFile = fopen (InfoName, "rb");
  31.   if (InfoFile == NULL) {
  32.     printf (Error1);
  33.     exit (1);
  34.   }
  35.   if (argc > 2) {
  36.     printf (Error2);
  37.     printf (Syntax);
  38.     exit (2);
  39.   }
  40.   if (argc == 2) {
  41.     strncpy (Param, argv[1], 5);
  42.     Param[5] = NULL;
  43.     MaxMsg = strtol (Param, NULL, 10);
  44.     if (MaxMsg > MAXMSG || MaxMsg < 0) {
  45.       printf (Error2);
  46.       printf (Syntax);
  47.       exit (2);
  48.     }
  49.   }
  50.   fread (&InfoBuff, sizeof (info_record), 1, InfoFile);
  51.   if (InfoBuff.HighMsg > MaxMsg) exit (3);
  52.   exit (0);
  53. }